
import {useFantasyStore} from "../store";

export function usePostMessage(message) {
    return new Promise((resolve, reject) => {
        try {

            const fantasy3DStore = useFantasyStore()
            const {
                mapStatus,
                $Dom
            } = fantasy3DStore

            if (mapStatus) {
                const iframe = $Dom
                iframe.contentWindow.postMessage(message,'*')
            }
            resolve('success')
        } catch (error) {
            reject(error)
        }
    })
}
